package com.laikan.reader.bookfriend.adapter.impl;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.laikan.reader.R;
import com.laikan.reader.article.activity.BookFocusDetailActivity;
import com.laikan.reader.bookfriend.adapter.AutherAdapter;
import com.laikan.reader.bookfriend.adapter.support.MultiItemTypeSupport;
import com.laikan.reader.bookfriend.entity.ItemShorteBean;
import com.laikan.reader.bookfriend.holder.LViewHolder;
import com.laikan.reader.bookfriend.utils.Constant;
import com.laikan.reader.bookfriend.utils.ImageUtils;

/**
 * Created by lingyt on 2016/11/15.
 * 支持加载更多的adapter
 */
public class ShorteAdapter extends AutherAdapter<ItemShorteBean> {


    public ShorteAdapter(Context context, int layoutId, MultiItemTypeSupport<ItemShorteBean> support) {
        super(context, layoutId, support);
    }

    @Override
    protected void convert(LViewHolder holder, final ItemShorteBean bean) {

        //initView
        SimpleDraweeView ivIcon = holder.getView(R.id.item_iv_icon);
        TextView tvTitle = holder.getView(R.id.item_tv_title);
        TextView reviewNum = holder.getView(R.id.item_tv_comment_num);
        TextView readNum = holder.getView(R.id.item_tv_read_num);

        //initData
        tvTitle.setText(bean.title);
        reviewNum.setText("评论 "+bean.reviewNum+"次");
        readNum.setText("阅读 "+bean.readNum+"次");
        if (!bean.type.equals("1")){//加载项不是-NO_IMG，才加载图片
            ivIcon.setImageURI(Uri.parse(bean.img));
        }


        //setListener
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //点击跳转到文章详情页
                ImageUtils.startActivity(BookFocusDetailActivity.class, Constant.ARTICLE_ID,bean.shorteId);
            }
        });
    }


}
